In triangle $ABC,$ $M$ is the midpoint of $\overline{BC},$ $AB = 12,$ and $AC = 16.$  Let $E$ be on $\overline{AC},$ and $F$ be on $\overline{AB},$ and let $G$ be the intersection of $\overline{EF}$ and $\overline{AM}.$  If $AE = 2AF,$ then find $\frac{EG}{GF}.$

[asy]
unitsize(0.3 cm);

pair A, B, C, E, F, G, M;
real x = 4;

B = (0,0);
C = (18,0);
A = intersectionpoint(arc(B,12,0,180),arc(C,16,0,180));
M = (B + C)/2;
F = interp(A,B,x/12);
E = interp(A,C,2*x/16);
G = extension(E,F,A,M);

draw(A--B--C--cycle);
draw(E--F);
draw(A--M);

label("$A$", A, N);
label("$B$", B, SW);
label("$C$", C, SE);
label("$E$", E, NE);
label("$F$", F, NW);
label("$G$", G, SW);
label("$M$", M, S);
[/asy]
Let $x = AF,$ so $AE = 2x.$  Then $BF = 12 - x$ and $CE = 16 - 2x.$

[asy]
unitsize(0.3 cm);

pair A, B, C, E, F, G, M;
real x = 4;

B = (0,0);
C = (18,0);
A = intersectionpoint(arc(B,12,0,180),arc(C,16,0,180));
M = (B + C)/2;
F = interp(A,B,x/12);
E = interp(A,C,2*x/16);
G = extension(E,F,A,M);

draw(A--B--C--cycle);
draw(E--F);
draw(A--M);

label("$A$", A, N);
label("$B$", B, SW);
label("$C$", C, SE);
label("$E$", E, NE);
label("$F$", F, NW);
label("$G$", G, SW);
label("$M$", M, S);
label("$x$", (A + F)/2, NW, red);
label("$2x$", (A + E)/2, NE, red);
label("$12 - x$", (B + F)/2, NW, red);
label("$16 - 2x$", (C + E)/2, NE, red);
[/asy]

Let $\mathbf{a}$ denote $\overrightarrow{A},$ etc.  Then
\[\mathbf{f} = \frac{x \mathbf{b} + (12 - x) \mathbf{a}}{12},\]so
\[\mathbf{b} = \frac{12 \mathbf{f} - (12 - x) \mathbf{a}}{x}.\]Also,
\[\mathbf{e} = \frac{2x \mathbf{c} + (16 - 2x) \mathbf{a}}{16} = \frac{x \mathbf{c} + (8 - x) \mathbf{a}}{8},\]so
\[\mathbf{c} = \frac{8 \mathbf{e} - (8 - x) \mathbf{a}}{x}.\]Then
\[\mathbf{m} = \frac{\mathbf{b} + \mathbf{c}}{2} = \frac{8 \mathbf{e} + 12 \mathbf{f} - (20 - 2x) \mathbf{a}}{2x} = \frac{4 \mathbf{e} + 6 \mathbf{f} - (10 - x) \mathbf{a}}{x}.\]Hence, $x \mathbf{m} + (10 - x) \mathbf{a} = 4 \mathbf{e} + 6 \mathbf{f},$ so
\[\frac{x}{10} \mathbf{m} + \frac{10 - x}{10} \mathbf{a} = \frac{4}{10} \mathbf{e} + \frac{6}{10} \mathbf{f}.\]Since the coefficients on both sides of the equation add up to 1, the vector on the left side lies on line $AM,$ and the vector on the right side lies on line $EF.$  Therefore, this common vector is $\mathbf{g}.$  Furthermore, $\frac{EG}{GF} = \frac{6}{4} = \boxed{\frac{3}{2}}.$